using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using DotNetMatrix;

namespace Blimpbots.Recognition
{
    public class Coalesce
    {
        //public static List<InterestWindow> CoalesceObjects(List<LikelyObject> detectedObjects, int maxPerWindow)
        //{
        //    List<InterestWindow> groupedObjects = new List<InterestWindow>();

        //    detectedObjects.Sort(
        //        delegate(LikelyObject o1, LikelyObject o2)
        //        { return o1.AffineModel.Score.CompareTo(o2.AffineModel.Score); });

        //    List<LikelyObject> group = null;
        //    List<LikelyObject> rest = detectedObjects;

        //    // Greedily coalesce detections into interest windows
        //    while(rest.Count > 0)
        //    {
        //        List<LikelyObject> nextRest = new List<LikelyObject>();
        //        LikelyObject prototype = rest[0];
        //        RectangleF boundRect = prototype.Example.BoundingBox;
        //        boundRect.Offset(-boundRect.Left, -boundRect.Top);

        //        // A transform mapping back to the data space for
        //        // for the prototype object.
        //        GeneralMatrix invH = prototype.AffineModel.H.Inverse();

        //        group = new List<LikelyObject>();
        //        group.Add(prototype);

        //        for(int i = 1; i < rest.Count; i++)
        //        {
        //            LikelyObject o = rest[i];
        //            Point2D c = Geometry.ProjectPoint(o.Center.x, o.Center.y, invH);

        //            if (boundRect.Contains(c.ToPointF()))
        //            {
        //                if(group.Count < maxPerWindow)
        //                    group.Add(o);
        //            }
        //            else
        //                nextRest.Add(o);
        //        }

        //        rest = nextRest;
        //        groupedObjects.Add(new InterestWindow(group));

        //    }

        //    return groupedObjects;

        //}


    }
}
